package com.ecoolex.chinadutyfree.retailer.core.manager;

import com.ecoolex.chinadutyfree.retailer.core.dao.DirectMailGoodsProductTotalDataDAO;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsProductTotalData;
import com.ecoolex.chinadutyfree.retailer.enums.DirectMailGoodsOrderStatus;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DirectMailGoodsProductTotalDataManager {
    @Autowired
    private DirectMailGoodsProductTotalDataDAO dao;
    
    /**
     * 统计直邮产品总量数据，定时任务每天凌晨0点执行一次
     */
    public void productTotalData(String updateUser) {
    	Date now = new Date();
    	dao.add(DirectMailGoodsOrderStatus.PAID.real(),
    		DirectMailGoodsOrderStatus.WAIT_RECECEIVE.real(),
    		DirectMailGoodsOrderStatus.COMPLETE.real(),
    		DirectMailGoodsOrderStatus.AFTER_SALES.real(),
    		updateUser,now, updateUser,now,DirectMailGoodsProductTotalData.NOT_DELETED);
    }
    
    /**
     * 获取最新的产品总量数据
     * @return
     */
    public DirectMailGoodsProductTotalData getLatest() {
    	return dao.getLatest();
    }
}